package com.lf.controller;

import com.lf.constant.ConstantsValue;
import com.lf.entity.ResponseWrapper;
import com.lf.entity.RevenuesEntity;
import com.lf.entity.vo.front.CheckRecordVo;
import com.lf.entity.vo.front.ReportVo;
import com.lf.entity.vo.front.UserVo;
import com.lf.enums.ErrorCodeEnum;
import com.lf.exception.ApiException;
import com.lf.jwt.CurrentManager;
import com.lf.jwt.SameUrlData;
import com.lf.service.ServiceList;
import com.lf.swagger.ApiJsonObject;
import com.lf.swagger.ApiJsonProperty;
import com.lf.util.Asserts;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: 用户接口【前端】
 * @description: 用户
 * @author: gxl
 * @create:
 **/
@Slf4j
@Api(value = "miniprogram", tags = "小程序接口")
@RestController
@RequestMapping("/miniprogram")
public class MiniProgramController extends ServiceList {


    /**
     * 提现
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/userWithDrawn", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]用户提现", response = String.class)
    public ResponseWrapper userWithDrawn(@ApiJsonObject(name = "userWithDrawnParams", value = {
            @ApiJsonProperty(key = "userId", value = "用户ID")
    }) @RequestBody JSONObject jsonParam){
        try {

            redisLockRegistry.obtain(ConstantsValue.COLONY_DRAWN_LOCK).lock();
            ConstantsValue.DRAWN_LOCK.writeLock().lock();
            Integer userId = jsonParam.getInteger("userId");
            Asserts.checkUserId(userId,"userId");
            return userService.userWithDrawn(userId);
        }catch (ApiException e){
            log.error(String.format("[前端]用户提现失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]用户提现失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }finally {
            ConstantsValue.DRAWN_LOCK.writeLock().unlock();
            redisLockRegistry.obtain(ConstantsValue.COLONY_DRAWN_LOCK).unlock();
        }
    }

    /**
     * 获取用户二维码
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getQrCode", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取用户二维码", response = String.class)
    public ResponseWrapper getQrCode(@ApiJsonObject(name = "getQrCodeParams", value = {}) @RequestBody JSONObject jsonParam){
        try {
            String userId = jsonParam.getString("userId");
            Asserts.checkUserId(Integer.valueOf(userId),"userId");

            return userService.getQrCode(Long.valueOf(userId));
        }catch (ApiException e){
            log.error(String.format("[前端]获取用户二维码失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取用户二维码失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 绑定上级
     * @param jsonParam
     * @return
     */
//    @SameUrlData
//    @RequestMapping(value = "/bindParent", method = RequestMethod.POST)
//    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]绑定上级", response = String.class)
//    public ResponseWrapper bindParent(@ApiJsonObject(name = "bindParentParams", value = {
//            @ApiJsonProperty(key = "jscode", value = "jscode")
//    }) @RequestBody JSONObject jsonParam){
//        try {
//            Long pid = jsonParam.getLong("pid");
//            String jscode = jsonParam.getString("jscode");
//
//            Asserts.checkUserId(Integer.valueOf(pid.toString()),"userId");
//            return userService.bindParent(jscode,pid);
//        }catch (ApiException e){
//            log.error(String.format("[前端]绑定上级失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
//            return ResponseWrapper.failed(e.getCode(), e.getMessage());
//        }catch (Exception e){
//            log.error(String.format("[前端]绑定上级失败"), e.getMessage());
//            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
//        }
//    }

    /**
     * 获取用户openid，也相当于注册
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getUserOpenId", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取用户openid", response = String.class)
    public ResponseWrapper getUserOpenId(@ApiJsonObject(name = "getUserOpenIdParams", value = {
            @ApiJsonProperty(key = "jscode", value = "jscode")
    }) @RequestBody JSONObject jsonParam){
        try {
            String jscode = jsonParam.getString("jscode");
            String pid = null;
            log.info("pid:{}",jsonParam.containsKey("pid"));
//            log.info("01,pid:{}",jsonParam.getString("pid"));
            if (jsonParam.containsKey("pid") && !jsonParam.getString("pid").isEmpty()){
                 pid = jsonParam.getString("pid");
                Asserts.naturalNumber(pid,"父id");
            }
            if (jsonParam.getString("pid") == null || "".equals(jsonParam.getString("pid"))){
                pid = "0";
            }
            log.info("1,pid:{}",pid);
            return userService.getUserOpenId(jscode, Long.valueOf(pid));
        }catch (ApiException e){
            log.error(String.format("[前端]获取用户openid失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取用户openid失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 核查比对 个人信息
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/checkName", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]核查比对", response = String.class)
    public ResponseWrapper checkName(
            @ApiJsonObject(name = "checkNameParams", value = {
                    @ApiJsonProperty(key = "realName", value = "姓名"),
                    @ApiJsonProperty(key = "code", value = "授权码"),
                    @ApiJsonProperty(key = "uid", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {

        try {
            String realName = jsonParam.getString("realName");
            String code = jsonParam.getString("code");
            Integer uid = jsonParam.getInteger("userId");//这里也可以使用uid
            Asserts.checkName(realName,"姓名");
            Asserts.checkCode(code,"授权码");
            Asserts.checkUserId(uid,"用户ID");

            UserVo userVo = userService.checkName(uid, realName, code);
            return ResponseWrapper.succeed(userVo);
        }catch (ApiException e){
            log.error(String.format("[前端]核查比对失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]核查比对失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取核查记录额，分页
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/getRecords", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取核查记录", response = String.class)
    public ResponseWrapper getRecords(
            @ApiJsonObject(name = "getRecordsParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID"),
                    @ApiJsonProperty(key = "page", value = "页码"),
                    @ApiJsonProperty(key = "limit", value = "行数"),
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = Integer.valueOf(jsonParam.getString("userId"));
            Integer pageSize = jsonParam.getInteger("page");
            Integer rows = jsonParam.getInteger("limit");
            Asserts.naturalNumber(pageSize, "页码");
            Asserts.naturalNumber(rows, "行数");
            Asserts.checkUserId(userId,"用户ID");

            List<CheckRecordVo>  checkRecordVos =  userService.getRecords(userId,pageSize,rows);
            return ResponseWrapper.succeed(checkRecordVos);
        }catch (ApiException e){
            log.error(String.format("[前端]获取核查记录失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取核查记录失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取下级用户列表，分页
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getChildRecords", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取下级用户列表", response = String.class)
    public ResponseWrapper getChildRecords(
            @ApiJsonObject(name = "getChildRecordsParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID"),
                    @ApiJsonProperty(key = "page", value = "页码"),
                    @ApiJsonProperty(key = "limit", value = "行数"),
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            Integer pageSize = jsonParam.getInteger("page");
            Integer rows = jsonParam.getInteger("limit");
            Asserts.naturalNumber(pageSize, "页码");
            Asserts.naturalNumber(rows, "行数");
            Asserts.checkUserId(userId,"用户ID");

            return userService.getChildRecords(userId,pageSize,rows);
        }catch (ApiException e){
            log.error(String.format("[前端]获取下级用户列表失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取下级用户列表失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取核查记录详情
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getRecordInfo", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取核查记录详情", response = String.class)
    public ResponseWrapper getRecordInfo(
            @ApiJsonObject(name = "getRecordInfoParams", value = {
                    @ApiJsonProperty(key = "id", value = "记录ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer id = jsonParam.getInteger("id");
            Asserts.naturalNumber(id,"核查记录ID");

            CheckRecordVo checkRecordVo =  userService.getRecordInfo(id);
            return ResponseWrapper.succeed(checkRecordVo);
        }catch (ApiException e){
            log.error(String.format("[前端]获取核查记录详情失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取核查记录详情失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 更新授权码
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/updateCode", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]更新授权码", response = String.class)
    public ResponseWrapper updateCode(
            @ApiJsonObject(name = "updateCodeParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = Integer.valueOf(jsonParam.getString("userId"));
            Asserts.checkUserId(userId,"用户ID");

            String code = userService.updateCode(userId);
            return ResponseWrapper.succeed(code);
        }catch (ApiException e){
            log.error(String.format("[前端]更新授权码失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]更新授权码失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取授权码
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/getCode", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取授权码", response = String.class)
    public ResponseWrapper getCode(
            @ApiJsonObject(name = "getCodeParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = Integer.valueOf(jsonParam.getString("userId"));
            Asserts.checkUserId(userId,"用户ID");

            String code = userService.getCode(userId);
            return ResponseWrapper.succeed(code);
        }catch (ApiException e){
            log.error(String.format("[前端]获取授权码失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取授权码失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取用户被吐槽记录，分页
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getReports", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]获取用户被吐槽记录", response = String.class)
    public ResponseWrapper getReports(
            @ApiJsonObject(name = "getReportsParams", value = {
                    @ApiJsonProperty(key = "beReportUserId", value = "被吐槽用户的id"),
                    @ApiJsonProperty(key = "page", value = "页码"),
                    @ApiJsonProperty(key = "limit", value = "行数"),
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer beReportUserId = jsonParam.getInteger("beReportUserId");
            Integer pageSize = jsonParam.getInteger("page");
            Integer rows = jsonParam.getInteger("limit");
            Asserts.naturalNumber(pageSize, "页码");
            Asserts.naturalNumber(rows, "行数");
            Asserts.naturalNumber(beReportUserId,"被吐槽用户的id");

            List<ReportVo>  reportVos =  userService.getReports(beReportUserId,pageSize,rows);
            return ResponseWrapper.succeed(reportVos);
        }catch (ApiException e){
            log.error(String.format("[前端]获取用户被吐槽记录失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取用户被吐槽记录失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 吐槽用户
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/reportUser", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]吐槽用户", response = String.class)
    public ResponseWrapper reportUser(
            @ApiJsonObject(name = "reportUserParams", value = {
                    @ApiJsonProperty(key = "reportUserId", value = "用户ID"),
                    @ApiJsonProperty(key = "beReportUserId", value = "被吐槽用户ID"),
                    @ApiJsonProperty(key = "reportContent", value = "吐槽内容")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");//这里也可以使用 reportUserId
            Integer beReportUserId = jsonParam.getInteger("beReportUserId");
            String reportContent = jsonParam.getString("reportContent");
            Asserts.checkUserId(userId, "用户ID");
            Asserts.naturalNumber(beReportUserId, "被吐槽用户ID");
            Asserts.notBlank(reportContent,"吐槽内容");

            userService.reportUser(userId,beReportUserId,reportContent);
            return ResponseWrapper.succeed();
        }catch (ApiException e){
            log.error(String.format("[前端]吐槽用户失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]吐槽用户失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 升级代理商
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/visitCode", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]升级代理商", response = String.class)
    public ResponseWrapper visitCode(
            @ApiJsonObject(name = "visitCodeParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            Asserts.checkUserId(userId, "用户ID");

            return userService.visitCode(userId);
        }catch (ApiException e){
            log.error(String.format("[前端]升级代理商失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]升级代理商失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 我的收益记录
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/myRevenues", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]我的收益记录", response = String.class)
    public ResponseWrapper myRevenues(
            @ApiJsonObject(name = "myRevenuesParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID"),
                    @ApiJsonProperty(key = "page", value = "页码"),
                    @ApiJsonProperty(key = "limit", value = "行数"),
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            Integer pageSize = jsonParam.getInteger("page");
            Integer rows = jsonParam.getInteger("limit");
            Asserts.naturalNumber(pageSize, "页码");
            Asserts.naturalNumber(rows, "行数");
            Asserts.checkUserId(userId,"用户ID");

            List<RevenuesEntity> revenuesEntities = userService.myRevenues(userId, pageSize, rows);
            return ResponseWrapper.succeed(revenuesEntities);
        }catch (ApiException e){
            log.error(String.format("[前端]获取我的收益记录失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取我的收益记录失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 获取用户收益
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/userRevenue", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]我的收益", response = String.class)
    public ResponseWrapper userRevenue(
            @ApiJsonObject(name = "userRevenueParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            Asserts.checkUserId(userId, "用户ID");

            UserVo  userVo = userService.userRevenue(userId);
            return ResponseWrapper.succeed(userVo);
        }catch (ApiException e){
            log.error(String.format("[前端]获取我的收益失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取我的收益失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }
    /**
     * 申请认证
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/applyAuth", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]申请认证", response = String.class)
    public ResponseWrapper applyAuth(
            @ApiJsonObject(name = "applyAuthParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID"),
                    @ApiJsonProperty(key = "head", value = "用户头像"),
                    @ApiJsonProperty(key = "cardA", value = "用户身份证正面"),
                    @ApiJsonProperty(key = "cardB", value = "用户身份证反面"),
                    @ApiJsonProperty(key = "mobile", value = "手机号"),
                    @ApiJsonProperty(key = "code", value = "验证码")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            String mobile = jsonParam.getString("mobile");
            String code = jsonParam.getString("code");
            String head = jsonParam.getString("head");
            String cardA = jsonParam.getString("cardA");
            String cardB = jsonParam.getString("cardB");
            Asserts.checkCode(code, "验证码");
            Asserts.checkMobile(mobile, "手机号");
            Asserts.checkUserId(userId, "用户ID");
            Asserts.notBlank(head, "个人照片");
            Asserts.notBlank(cardA, "用户身份证正面");
            Asserts.notBlank(cardB, "用户身份证反面");

            userService.applyAuth(userId, head, cardA, cardB, mobile, code);
            return ResponseWrapper.succeed("已提交申请");
        }catch (ApiException e){
            log.error(String.format("[前端]申请认证失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]申请认证失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     * 认证状态
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/authStatus", method = RequestMethod.POST)
    @ApiOperation(tags = "小程序接口", httpMethod = "POST", value = "[前端]认证状态", response = String.class)
    public ResponseWrapper authStatus(
            @ApiJsonObject(name = "authStatusParams", value = {
                    @ApiJsonProperty(key = "userId", value = "用户ID")
            }) @RequestBody JSONObject jsonParam) {
        try {
            Integer userId = jsonParam.getInteger("userId");
            Asserts.checkUserId(userId, "用户ID");

            String status = userService.authStatus(userId);
            return ResponseWrapper.succeed(status);
        }catch (ApiException e){
            log.error(String.format("[前端]获取认证状态失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取认证状态失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     *用户手机验证码
     * @param jsonParam
     * @return
     */
    @SameUrlData
    @RequestMapping(value = "/getVerificationCode", method = RequestMethod.POST)
    @ApiOperation(tags = "用户", httpMethod = "POST", value = "[前端]用户手机验证码", response = String.class)
    public ResponseWrapper getVerificationCode(
            @ApiJsonObject(name = "getVerificationCodeParams", value = {
                    @ApiJsonProperty(key = "mobile", value = "手机号")
            }) @RequestBody JSONObject jsonParam) {
        try {
            String mobile = jsonParam.getString("mobile");
            Asserts.checkMobile(mobile,"手机号码");

            userService.sendVerificationCode(mobile);
            return ResponseWrapper.succeed("发送成功");
        }catch (ApiException e){
            log.error(String.format("[前端]用户获取验证码失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]用户获取验证码失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }

    /**
     *获取敏感功能状态
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/loadData", method = RequestMethod.POST)
    @ApiOperation(tags = "用户", httpMethod = "POST", value = "[前端]获取敏感功能状态", response = String.class)
    public ResponseWrapper loadData(@ApiJsonObject(name = "loadDataParams", value = {}) @RequestBody JSONObject jsonParam) {
        try {
            return userService.loadData();
        }catch (ApiException e){
            log.error(String.format("[前端]获取敏感功能状态失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
            return ResponseWrapper.failed(e.getCode(), e.getMessage());
        }catch (Exception e){
            log.error(String.format("[前端]获取敏感功能状态失败"), e);
            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
        }
    }


//    @CurrentManager
//    @RequestMapping(value = "/getRecommedAndTeam", method = RequestMethod.POST)
//    @ApiOperation(tags = "用户", httpMethod = "POST", value = "[前端]获取用户直推人数和团队人数", response = RTVo.class)
//    public ResponseWrapper getRecommedAndTeam(
//            @ApiJsonObject(name = "getRecommedAndTeamParams", value = {}) @RequestBody JSONObject jsonParam) {
//
//        try {
//            String account = jsonParam.getString("account");
//            Asserts.notBlank(account, "用户名");
//
//            RTVo vo = userService.getRecommedAndTeam(account);
//            return ResponseWrapper.succeed(vo);
//
//        }catch (ApiException e){
//            log.error(String.format("[前端]获取用户直推人数和团队人数失败，参数:%s, 错误信息:%s", jsonParam.toJSONString(), e.getMessage()));
//            return ResponseWrapper.failed(e.getCode(), e.getMessage());
//        }catch (Exception e){
//            log.error(String.format("[前端]获取用户直推人数和团队人数失败"), e.getMessage());
//            return ResponseWrapper.failed(ErrorCodeEnum.FL500);
//        }
//    }

}
